package com.yunqiao.admin.modules.api.controller;

import com.yunqiao.common.utils.PageUtils;
import com.yunqiao.common.utils.R;
import com.yunqiao.service.api.OrderCashService;
import com.yunqiao.service.api.entity.OrderCashEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 押金订单信息
 * @company 今日速运
 * @author Crocutax
 * @email wangxw725@foxmail.com
 * @date 2019-04-11 18:54:10
 */
@RestController
@RequestMapping("api/ordercash")
public class OrderCashController {

    @Autowired
    private OrderCashService orderCashService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("api:ordercash:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderCashService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("api:ordercash:info")
    public R info(@PathVariable("id") Long id){
        OrderCashEntity orderCash = orderCashService.getById(id);
        return R.ok().put("orderCash", orderCash);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("api:ordercash:save")
    public R save(@RequestBody OrderCashEntity orderCash){
        orderCashService.save(orderCash);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("api:ordercash:update")
    public R update(@RequestBody OrderCashEntity orderCash){
        orderCashService.updateById(orderCash);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("api:ordercash:delete")
    public R delete(@RequestBody Long[] ids){
        orderCashService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
